import Cookies from 'js-cookie'
const system = {
  state: {
    sidebar: {
      opened: !+Cookies.get('sidebarStatus'),
      withoutAnimation: false
    },
  },
  mutations: {
    TOGGLE_SIDEBAR: state => {
      if (state.sidebar.opened) {
        Cookies.set('sidebarStatus', 1)
      } else {
        Cookies.set('sidebarStatus', 0)
      }

      console.log(state.sidebar.opened)
      state.sidebar.opened = !state.sidebar.opened
      state.sidebar.withoutAnimation = false
    },
    OPEN_SIDEBAR : state => {
      state.sidebar.opened = true;
      Cookies.set('sidebarStatus', 1)
    },
    CLOSE_SIDEBAR : state => {
      state.sidebar.opened = false;
      Cookies.set('sidebarStatus', 0)
    }
    // CLOSE_SIDEBAR: (state, withoutAnimation) => {
    //   Cookies.set('sidebarStatus', 1)
    //   state.sidebar.opened = false
    //   state.sidebar.withoutAnimation = withoutAnimation
    // },
  },
  actions: {
    toggleSideBar({ commit }) {
      commit('TOGGLE_SIDEBAR')
    },
    openSideBar({commit}){
      commit('OPEN_SIDEBAR')
    },
    closeSideBar({ commit }) {
      commit('CLOSE_SIDEBAR')
    }
  }
}

export default system
